<script type="text/javascript">
$(document).ready(function() 
{	
	function openMsgDialog(msg)
	{
		$('#dialog_msg').html(msg).dialog({
			autoOpen: true,
			modal: true,
			show: 'fade',
			resizable: 'false',				
			buttons: { "<?php echo html_entity_decode($this->translator->translator('common_ok'), ENT_QUOTES, 'UTF-8'); ?>": function() { $(this).dialog('option', 'hide', 'explode').dialog("close"); } },
			open: function(event, ui)
				 {
					setTimeout(function() 
					{									
						if($('#' + event.target.id).dialog('isOpen'))
						{
							$('#' + event.target.id).dialog('option', 'hide', 'explode').dialog('close');										
						}
					}, 10000);
				  }
		});
	}
	
	$('a.add_user_btn').click(function() {
		var role_id = '';	
		$.each($('#GroupForm').serializeArray(), function(i, field) {			
			role_id = (field.name == 'role_id') ? field.value : '';			
		});				
		if(role_id == '')
		{
			openMsgDialog("<?php echo $this->translator->translator('Member_group_page_select_err'); ?>");
		}
		else
		{
			var links = "<?php echo $this->serverUrl().$this->url(array('module' => 'Members','controller'=>'index', 'action'=>'add', 'role_id' => ''),'adminrout',true);?>";
			$(this).attr('href',links+role_id);
			document.location.href=links+role_id;
		}
	});
	
});
</script>
<div id="container">
<?php if (!$this->allow('add')) : ?>
	<div class="grid_12 t_a_bottom">
		<?php echo $this->translator->translator('Member_Access_deny_desc'); ?>
	</div>
<?php else :  ?>

<div class="title-container">
	<div class="role-option"><h1><?php echo $this->translator->translator('Member_group_page_name'); ?></h1></div>
</div>

<div class="content-container">
	<div id="sidebar-inner">
    	<?php  echo $this->partial('index/member_menu.phtml');  ?>	
    </div>
    
    <div id="content-inner">
    	<form name="GroupForm" id="GroupForm">
            <div id="actionMessage"></div>
            <fieldset class="fieldset">	
            	<legend class="legend"><?php echo $this->groupForm->role_id->getLabel(); if($this->groupForm->role_id->isRequired() ){ ?><span class="required">*</span><?php } ?></legend>
                <div class="form">
					<div class="form-row">
						<div class="label label-small">&nbsp;</div>
						<div class="field field-big">
							<?php echo $this->groupForm->role_id ; ?>
						</div>
					</div>
				</div>                 
                <div class="clr form-button-container">
                    <span class="button ui-widget-content-1"><a href="javascript:  void(0);" class="add_user_btn"><span class="icon user"><?php echo $this->translator->translator('Member_go_to_add_user_page'); ?></span></a></span>
                </div>                
            </fieldset>
        </form>
    </div>
</div>

<div id="dialog_msg" title="<?php echo $this->translator->translator('common_dialog_msg',$this->translator->translator('Member_group_page_name')); ?>">
</div>
<?php endif; ?>
</div>